Public Class RankingOracoes
    Inherits CollectionBase

    Public Enum Ordenacao
        PontuacaoCrescente
        PontuacaoDecrescente
        OrdemCrescente
    End Enum

    Public Overloads Sub Add(ByVal obj As Object)
        InnerList.Add(obj)
    End Sub

    Public Overloads Function Item(ByVal index As Integer) As Oracao
        Return CType(InnerList.Item(index), Oracao)
    End Function

    Public Sub RemoveByObject(ByVal o As Oracao)
        'Dim idx As Integer = -1
        'Dim i As Integer = 0
        'For Each o As Oracao In InnerList
        '    If sentence = o.frase Then
        '        idx = i
        '        Exit For
        '    End If
        '    i += 1
        'Next
        InnerList.Remove(o)
    End Sub

    Public Sub Sort(ByVal sorter As Ordenacao)
        Select Case sorter
            Case Ordenacao.PontuacaoCrescente
                InnerList.Sort(New AscendenteOracaoSorter)
            Case Ordenacao.PontuacaoDecrescente
                InnerList.Sort(New DesendenteOracaoSorter)
            Case Ordenacao.OrdemCrescente
                InnerList.Sort(New AscendenteOrdemSorter)
        End Select
    End Sub

    Private Class AscendenteOracaoSorter
        Implements IComparer

        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
            If x.pontuacao < y.pontuacao Then
                Return -1
            ElseIf x.pontuacao = y.pontuacao Then
                Return 0
            ElseIf x.pontuacao > y.pontuacao Then
                Return 1
            End If
        End Function

    End Class

    Private Class DesendenteOracaoSorter
        Implements IComparer

        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
            If x.pontuacao > y.pontuacao Then
                Return -1
            ElseIf x.pontuacao = y.pontuacao Then
                Return 0
            ElseIf x.pontuacao < y.pontuacao Then
                Return 1
            End If
        End Function
    End Class

    Private Class AscendenteOrdemSorter
        Implements IComparer

        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
            If x.ordem < y.ordem Then
                Return -1
            ElseIf x.ordem = y.ordem Then
                Return 0
            ElseIf x.ordem > y.ordem Then
                Return 1
            End If
        End Function

    End Class

End Class
